<template>
  <div>
    <Topnav titleTExt="我的跟帖" />
    <div v-for="(item, index) in commentList" :key="index">
      <div class="list header">
        <div class="item">
          <div class="date">{{ item.create_date.split("T")[0] }}</div>
          <div class="title">{{ item.content }}</div>
          <div class="content">{{ item.post.title }}</div>
        </div>
      </div>
      <div class="list">
        <div class="item" v-if="item.parent">
          <div class="date">{{ item.create_date.split("T")[0] }}</div>
          <div class="reply">
            <div class="title">回复：{{ item.parent.user.nickname }}</div>
            <div class="content">{{ item.post.title }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Topnav from "@/components/Topnav";
export default {
  data() {
    return {
      commentList: {},
    };
  },
  components: {
    Topnav,
  },
  created() {
    this.$axios({
      url: "/user_comments",
    }).then((res) => {
      console.log(res.data);
      this.commentList = res.data.data;
    });
  },
};
</script>

<style lang="less" scoped>
.header {
  border-bottom: 1px solid #ececec;
}
.list {
  padding: 0 20px;
  line-height: 2.5;

  .date {
    color: #888;
  }
  .title {
    font-size: 16px;
    color: #333;
  }
  .content {
    font-size: 14px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .reply {
    padding: 10px;
    border-radius: 10px;
    background-color: #ececec;
  }
}
</style>
